package com.lagou.service.impl;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.lagou.common.ResponseResult;

public class SentinelHandlers {

    // 整体要求和当时Hystrix一样，这里还需要在形参最后添加BlockException参数，用于接收异常
    // 注意：方法是静态的
    public static ResponseResult<Boolean> handleException(Long userId, BlockException blockException) {
        // 触发了降级
        return ResponseResult.exception("触发了降级: " + blockException.getMessage());
    }

    public static ResponseResult<Boolean> handleError(Long userId) {
        return ResponseResult.exception("邮件发送失败, 请重试");
    }

}
